/**
 * 简单建造者
 */
public class ProductTest {
    public static void main(String[] args) {
        Product3 builder = new Product3.Builder().name("123").builder();
        System.out.println(builder);
    }
}

class Product3 {
    private final String name;
    private final String password;
    private final String part1;
    private final String part2;
    private final String part3;
    private final String part4;
    private final String part5;
    // ......

    //建造者静态内部类
    public static class Builder{
       private String name;
       private String password;
       private String part1;
       private String part2;
       private String part3;
       private String part4;
       private String part5;

       public Builder name(String name){
           this.name = name;
           return this;
       }
        public Builder password(String password){
            this.password = password;
            return this;
        }
        public Builder part1(String part1){
           this.part1 = part1;
           return this;
        }
        public Builder part2(String part2){
            this.part2 = part2;
            return this;
        }
        public Builder part3(String part3){
            this.part3 = part3;
            return this;
        }
        public Builder part4(String part4){
            this.part4 = part4;
            return this;
        }
        public Builder part5(String part5){
            this.part5 = part5;
            return this;
        }

        Product3 builder(){
           return new Product3(this.name,this.password,this.part1,this.part2,this.part3,this.part4,this.part5);
        }
    }

    public Product3(String name, String password, String part1, String part2, String part3, String part4, String part5) {
        this.name = name;
        this.password = password;
        this.part1 = part1;
        this.part2 = part2;
        this.part3 = part3;
        this.part4 = part4;
        this.part5 = part5;
    }


    @Override
    public String toString() {
        return "Product2{" +
                "name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", part1='" + part1 + '\'' +
                ", part2='" + part2 + '\'' +
                ", part3='" + part3 + '\'' +
                ", part4='" + part4 + '\'' +
                ", part5='" + part5 + '\'' +
                '}';
    }
}
